package com.meibei.ljl.mymusic.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by xy on 16/10/11.
 */
public abstract class BaseFragment extends Fragment {

    protected View mView;
    protected LayoutInflater inflater;
    protected ViewGroup container;
    protected Context context;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.container = container;
        this.inflater = inflater;
        context = getActivity();
        if (getLayoutId() != 0) {
            mView = inflater.inflate(getLayoutId(), null);
            initView();
            setListener();
            initData();
        }
        return mView;
    }

    /**
     * 设置布局文件
     */
    public abstract int getLayoutId();

    /**
     * 初始化控件
     */
    public abstract void initView();

    /**
     * 设置控件的监听
     */
    public abstract void setListener();

    /**
     * 初始化数据
     */
    public abstract void initData();
}
